package com.woniuxy.caradmin.controller;

import com.woniuxy.caradmin.entity.pojo.Remind;
import com.woniuxy.caradmin.exception.CarException;
import com.woniuxy.caradmin.service.RemindService;
import com.woniuxy.caradmin.util.Constaint;
import com.woniuxy.caradmin.util.DataGridView;
import com.woniuxy.caradmin.util.R;
import com.woniuxy.caradmin.util.ResultCode;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/remind")
public class RemindController {
    @Autowired
    private RemindService remindService;
    @ApiOperation(value = "年检、保养、保险到期检查")
    @GetMapping(value = "/checkExpiretime")
    public R checkExpiretime(){
        boolean flag = remindService.selectExpiretime();
        if(flag){
            return R.ok().code(ResultCode.EXPIRETIMECHECKED).message(Constaint.EXPIRETIMECHECKED);
        }else{
            throw new CarException(ResultCode.ERROR,Constaint.ERROR);
        }
    }
    @ApiOperation(value = "获取到期提醒集合")
    @GetMapping(value = "/selectAllRemind")
    public R selectAllRemind(){
        List<Remind> remindList = remindService.selectAllRemind();
        if (remindList != null&&remindList.size()>0) {
            return R.ok().code(ResultCode.REMINDSUC).message(Constaint.REMINDSUC);
        }else{
            throw new CarException(ResultCode.ERROR,Constaint.ERROR);
        }
    }
    @ApiOperation(value = "获取layui页面的到期提醒")
    @GetMapping(value = "/getRemindList")
    public DataGridView getRemindList(){
        return null;
    }
}
